package cn.edu.scau.cmi.liyunlin.composite.safeComposite;

import java.util.ArrayList;

public class SafeTeam extends SafeOrganization {
	
	public SafeTeam(String name) {
		super(name);
	}
	
	private ArrayList<SafeOrganization> organizationArrayList = new ArrayList<SafeOrganization>();
	
	public void add(SafeOrganization organization) {
		this.organizationArrayList.add(organization);
	}
	
	public void remove(SafeOrganization organization) {
		this.organizationArrayList.remove(organization);
	}

	@Override
	public void display(int depth) {
		// TODO Auto-generated method stub

		for(int i = 0; i < depth; i++) {
			System.out.print('-');
		}
		System.out.println(name);
		
		for(SafeOrganization organization: organizationArrayList) {
			organization.display(depth + 1);
		}
	}

	@Override
	public String output(int depth) {
		// TODO Auto-generated method stub
		String str = "";
		for(int i = 0; i < depth; i++) {
			//System.out.print('-');
			str += '-';
		}
		//System.out.println(name);
		str += name;
		str += '\n';
		
		for(SafeOrganization organization: organizationArrayList) {
			str += organization.output(depth + 1);
		}
		return str;
	}
}
